﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using V5_DBUtility;
using V5_Model;

using System.Data.OleDb;
namespace V5_DAL.OleDb
{
    public class DALProduct 
    {

        #region  BaseMethod
        /// <summary>
        /// 得到最大ID
        /// </summary>
        public int GetMaxId() {
            return DbHelperOleDb.GetMaxID("ID", "K_Product");
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ID) {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from K_Product");
            strSql.Append(" where ID=" + ID);
            return DbHelperOleDb.Exists(strSql.ToString());
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(ModelProduct model) {
            StringBuilder strSql = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();
            if (model.ID != null) {
                strSql1.Append("ID,");
                strSql2.Append("" + model.ID + ",");
            }
            if (model.ChannelID != null) {
                strSql1.Append("ChannelID,");
                strSql2.Append("" + model.ChannelID + ",");
            }
            if (model.ClassID != null) {
                strSql1.Append("ClassID,");
                strSql2.Append("" + model.ClassID + ",");
            }
            if (model.ProductName != null) {
                strSql1.Append("ProductName,");
                strSql2.Append("'" + model.ProductName + "',");
            }
            if (model.ProductKeysWords != null) {
                strSql1.Append("ProductKeysWords,");
                strSql2.Append("'" + model.ProductKeysWords + "',");
            }
            if (model.ProductCode != null) {
                strSql1.Append("ProductCode,");
                strSql2.Append("'" + model.ProductCode + "',");
            }
            if (model.ProductBrand != null) {
                strSql1.Append("ProductBrand,");
                strSql2.Append("'" + model.ProductBrand + "',");
            }
            if (model.ProductUnit != null) {
                strSql1.Append("ProductUnit,");
                strSql2.Append("'" + model.ProductUnit + "',");
            }
            if (model.ProductWeight != null) {
                strSql1.Append("ProductWeight,");
                strSql2.Append("'" + model.ProductWeight + "',");
            }
            if (model.ProductMarketPrice != null) {
                strSql1.Append("ProductMarketPrice,");
                strSql2.Append("'" + model.ProductMarketPrice + "',");
            }
            if (model.ProductMemberPrice != null) {
                strSql1.Append("ProductMemberPrice,");
                strSql2.Append("'" + model.ProductMemberPrice + "',");
            }
            if (model.ProductMinPrice != null) {
                strSql1.Append("ProductMinPrice,");
                strSql2.Append("'" + model.ProductMinPrice + "',");
            }
            if (model.ProductBigPic != null) {
                strSql1.Append("ProductBigPic,");
                strSql2.Append("'" + model.ProductBigPic + "',");
            }
            if (model.ProductSmallPic != null) {
                strSql1.Append("ProductSmallPic,");
                strSql2.Append("'" + model.ProductSmallPic + "',");
            }
            if (model.ProductMorePic != null) {
                strSql1.Append("ProductMorePic,");
                strSql2.Append("'" + model.ProductMorePic + "',");
            }
            if (model.ProductCount != null) {
                strSql1.Append("ProductCount,");
                strSql2.Append("" + model.ProductCount + ",");
            }
            if (model.ProductFieldType != null) {
                strSql1.Append("ProductFieldType,");
                strSql2.Append("" + model.ProductFieldType + ",");
            }
            if (model.ProductFields != null) {
                strSql1.Append("ProductFields,");
                strSql2.Append("'" + model.ProductFields + "',");
            }
            if (model.ProductSingleFields != null) {
                strSql1.Append("ProductSingleFields,");
                strSql2.Append("'" + model.ProductSingleFields + "',");
            }
            if (model.ProductSizeTable != null) {
                strSql1.Append("ProductSizeTable,");
                strSql2.Append("'" + model.ProductSizeTable + "',");
            }
            if (model.IsPassed != null) {
                strSql1.Append("IsPassed,");
                strSql2.Append("" + model.IsPassed + ",");
            }
            if (model.IsOnSale != null) {
                strSql1.Append("IsOnSale,");
                strSql2.Append("" + model.IsOnSale + ",");
            }
            if (model.IsRecommond != null) {
                strSql1.Append("IsRecommond,");
                strSql2.Append("" + model.IsRecommond + ",");
            }
            if (model.IsOnHot != null) {
                strSql1.Append("IsOnHot,");
                strSql2.Append("" + model.IsOnHot + ",");
            }
            if (model.IsNew != null) {
                strSql1.Append("IsNew,");
                strSql2.Append("" + model.IsNew + ",");
            }
            if (model.IsSpecialOffer != null) {
                strSql1.Append("IsSpecialOffer,");
                strSql2.Append("" + model.IsSpecialOffer + ",");
            }
            if (model.Package != null) {
                strSql1.Append("Package,");
                strSql2.Append("" + model.Package + ",");
            }
            if (model.ShortContent != null) {
                strSql1.Append("ShortContent,");
                strSql2.Append("'" + model.ShortContent + "',");
            }
            if (model.Content != null) {
                strSql1.Append("Content,");
                strSql2.Append("'" + model.Content + "',");
            }
            if (model.ProductRelated != null) {
                strSql1.Append("ProductRelated,");
                strSql2.Append("'" + model.ProductRelated + "',");
            }
            if (model.Hits != null) {
                strSql1.Append("Hits,");
                strSql2.Append("" + model.Hits + ",");
            }
            if (model.AddDateTime != null) {
                strSql1.Append("AddDateTime,");
                strSql2.Append("'" + model.AddDateTime + "',");
            }
            if (model.UpDateTime != null) {
                strSql1.Append("UpDateTime,");
                strSql2.Append("'" + model.UpDateTime + "',");
            }
            if (model.XjIDs != null) {
                strSql1.Append("XjIDs,");
                strSql2.Append("'" + model.XjIDs + "',");
            }
            strSql.Append("insert into K_Product(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ModelProduct model) {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update K_Product set ");
            if (model.ChannelID != null) {
                strSql.Append("ChannelID=" + model.ChannelID + ",");
            }
            if (model.ClassID != null) {
                strSql.Append("ClassID=" + model.ClassID + ",");
            }
            if (model.ProductName != null) {
                strSql.Append("ProductName='" + model.ProductName + "',");
            }
            if (model.ProductKeysWords != null) {
                strSql.Append("ProductKeysWords='" + model.ProductKeysWords + "',");
            }
            if (model.ProductCode != null) {
                strSql.Append("ProductCode='" + model.ProductCode + "',");
            }
            if (model.ProductBrand != null) {
                strSql.Append("ProductBrand='" + model.ProductBrand + "',");
            }
            if (model.ProductUnit != null) {
                strSql.Append("ProductUnit='" + model.ProductUnit + "',");
            }
            if (model.ProductWeight != null) {
                strSql.Append("ProductWeight='" + model.ProductWeight + "',");
            }
            if (model.ProductMarketPrice != null) {
                strSql.Append("ProductMarketPrice='" + model.ProductMarketPrice + "',");
            }
            if (model.ProductMemberPrice != null) {
                strSql.Append("ProductMemberPrice='" + model.ProductMemberPrice + "',");
            }
            if (model.ProductMinPrice != null) {
                strSql.Append("ProductMinPrice='" + model.ProductMinPrice + "',");
            }
            if (model.ProductBigPic != null) {
                strSql.Append("ProductBigPic='" + model.ProductBigPic + "',");
            }
            if (model.ProductSmallPic != null) {
                strSql.Append("ProductSmallPic='" + model.ProductSmallPic + "',");
            }
            if (model.ProductMorePic != null) {
                strSql.Append("ProductMorePic='" + model.ProductMorePic + "',");
            }
            if (model.ProductCount != null) {
                strSql.Append("ProductCount=" + model.ProductCount + ",");
            }
            if (model.ProductFieldType != null) {
                strSql.Append("ProductFieldType=" + model.ProductFieldType + ",");
            }
            if (model.ProductFields != null) {
                strSql.Append("ProductFields='" + model.ProductFields + "',");
            }
            if (model.ProductSingleFields != null) {
                strSql.Append("ProductSingleFields='" + model.ProductSingleFields + "',");
            }
            if (model.ProductSizeTable != null) {
                strSql.Append("ProductSizeTable='" + model.ProductSizeTable + "',");
            }
            if (model.IsPassed != null) {
                strSql.Append("IsPassed=" + model.IsPassed + ",");
            }
            if (model.IsOnSale != null) {
                strSql.Append("IsOnSale=" + model.IsOnSale + ",");
            }
            if (model.IsRecommond != null) {
                strSql.Append("IsRecommond=" + model.IsRecommond + ",");
            }
            if (model.IsOnHot != null) {
                strSql.Append("IsOnHot=" + model.IsOnHot + ",");
            }
            if (model.IsNew != null) {
                strSql.Append("IsNew=" + model.IsNew + ",");
            }
            if (model.IsSpecialOffer != null) {
                strSql.Append("IsSpecialOffer=" + model.IsSpecialOffer + ",");
            }
            if (model.Package != null) {
                strSql.Append("Package=" + model.Package + ",");
            }
            if (model.ShortContent != null) {
                strSql.Append("ShortContent='" + model.ShortContent + "',");
            }
            if (model.Content != null) {
                strSql.Append("Content='" + model.Content + "',");
            }
            if (model.ProductRelated != null) {
                strSql.Append("ProductRelated='" + model.ProductRelated + "',");
            }
            if (model.Hits != null) {
                strSql.Append("Hits=" + model.Hits + ",");
            }
            if (model.AddDateTime != null) {
                strSql.Append("AddDateTime='" + model.AddDateTime + "',");
            }
            if (model.UpDateTime != null) {
                strSql.Append("UpDateTime='" + model.UpDateTime + "',");
            }
            if (model.XjIDs != null) {
                strSql.Append("XjIDs='" + model.XjIDs + "',");
            }
            int n = strSql.ToString().LastIndexOf(",");
            strSql.Remove(n, 1);
            strSql.Append(" where ID=" + model.ID + " ");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0) {
                return true;
            }
            else {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int ID) {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from K_Product ");
            strSql.Append(" where ID=" + ID);
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0) {
                return true;
            }
            else {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ModelProduct GetModel(int ID) {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from K_Product ");
            strSql.Append(" where ID=" + ID);
            ModelProduct model = new ModelProduct();
            DataSet ds = DbHelperOleDb.Query(strSql.ToString());
            if (ds != null && ds.Tables[0].Rows.Count > 0) {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "") {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ChannelID"] != null && ds.Tables[0].Rows[0]["ChannelID"].ToString() != "") {
                    model.ChannelID = int.Parse(ds.Tables[0].Rows[0]["ChannelID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ClassID"] != null && ds.Tables[0].Rows[0]["ClassID"].ToString() != "") {
                    model.ClassID = int.Parse(ds.Tables[0].Rows[0]["ClassID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductName"] != null && ds.Tables[0].Rows[0]["ProductName"].ToString() != "") {
                    model.ProductName = ds.Tables[0].Rows[0]["ProductName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductKeysWords"] != null && ds.Tables[0].Rows[0]["ProductKeysWords"].ToString() != "") {
                    model.ProductKeysWords = ds.Tables[0].Rows[0]["ProductKeysWords"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductCode"] != null && ds.Tables[0].Rows[0]["ProductCode"].ToString() != "") {
                    model.ProductCode = ds.Tables[0].Rows[0]["ProductCode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductBrand"] != null && ds.Tables[0].Rows[0]["ProductBrand"].ToString() != "") {
                    model.ProductBrand = ds.Tables[0].Rows[0]["ProductBrand"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductUnit"] != null && ds.Tables[0].Rows[0]["ProductUnit"].ToString() != "") {
                    model.ProductUnit = ds.Tables[0].Rows[0]["ProductUnit"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductWeight"] != null && ds.Tables[0].Rows[0]["ProductWeight"].ToString() != "") {
                    model.ProductWeight = ds.Tables[0].Rows[0]["ProductWeight"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductMarketPrice"] != null && ds.Tables[0].Rows[0]["ProductMarketPrice"].ToString() != "") {
                    model.ProductMarketPrice = ds.Tables[0].Rows[0]["ProductMarketPrice"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductMemberPrice"] != null && ds.Tables[0].Rows[0]["ProductMemberPrice"].ToString() != "") {
                    model.ProductMemberPrice = ds.Tables[0].Rows[0]["ProductMemberPrice"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductMinPrice"] != null && ds.Tables[0].Rows[0]["ProductMinPrice"].ToString() != "") {
                    model.ProductMinPrice = ds.Tables[0].Rows[0]["ProductMinPrice"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductBigPic"] != null && ds.Tables[0].Rows[0]["ProductBigPic"].ToString() != "") {
                    model.ProductBigPic = ds.Tables[0].Rows[0]["ProductBigPic"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductSmallPic"] != null && ds.Tables[0].Rows[0]["ProductSmallPic"].ToString() != "") {
                    model.ProductSmallPic = ds.Tables[0].Rows[0]["ProductSmallPic"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductMorePic"] != null && ds.Tables[0].Rows[0]["ProductMorePic"].ToString() != "") {
                    model.ProductMorePic = ds.Tables[0].Rows[0]["ProductMorePic"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductCount"] != null && ds.Tables[0].Rows[0]["ProductCount"].ToString() != "") {
                    model.ProductCount = int.Parse(ds.Tables[0].Rows[0]["ProductCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductFieldType"] != null && ds.Tables[0].Rows[0]["ProductFieldType"].ToString() != "") {
                    model.ProductFieldType = int.Parse(ds.Tables[0].Rows[0]["ProductFieldType"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductFields"] != null && ds.Tables[0].Rows[0]["ProductFields"].ToString() != "") {
                    model.ProductFields = ds.Tables[0].Rows[0]["ProductFields"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductSingleFields"] != null && ds.Tables[0].Rows[0]["ProductSingleFields"].ToString() != "") {
                    model.ProductSingleFields = ds.Tables[0].Rows[0]["ProductSingleFields"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductSizeTable"] != null && ds.Tables[0].Rows[0]["ProductSizeTable"].ToString() != "") {
                    model.ProductSizeTable = ds.Tables[0].Rows[0]["ProductSizeTable"].ToString();
                }
                if (ds.Tables[0].Rows[0]["IsPassed"] != null && ds.Tables[0].Rows[0]["IsPassed"].ToString() != "") {
                    model.IsPassed = int.Parse(ds.Tables[0].Rows[0]["IsPassed"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsOnSale"] != null && ds.Tables[0].Rows[0]["IsOnSale"].ToString() != "") {
                    model.IsOnSale = int.Parse(ds.Tables[0].Rows[0]["IsOnSale"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsRecommond"] != null && ds.Tables[0].Rows[0]["IsRecommond"].ToString() != "") {
                    model.IsRecommond = int.Parse(ds.Tables[0].Rows[0]["IsRecommond"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsOnHot"] != null && ds.Tables[0].Rows[0]["IsOnHot"].ToString() != "") {
                    model.IsOnHot = int.Parse(ds.Tables[0].Rows[0]["IsOnHot"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsNew"] != null && ds.Tables[0].Rows[0]["IsNew"].ToString() != "") {
                    model.IsNew = int.Parse(ds.Tables[0].Rows[0]["IsNew"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsSpecialOffer"] != null && ds.Tables[0].Rows[0]["IsSpecialOffer"].ToString() != "") {
                    model.IsSpecialOffer = int.Parse(ds.Tables[0].Rows[0]["IsSpecialOffer"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Package"] != null && ds.Tables[0].Rows[0]["Package"].ToString() != "") {
                    model.Package = int.Parse(ds.Tables[0].Rows[0]["Package"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ShortContent"] != null && ds.Tables[0].Rows[0]["ShortContent"].ToString() != "") {
                    model.ShortContent = ds.Tables[0].Rows[0]["ShortContent"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Content"] != null && ds.Tables[0].Rows[0]["Content"].ToString() != "") {
                    model.Content = ds.Tables[0].Rows[0]["Content"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductRelated"] != null && ds.Tables[0].Rows[0]["ProductRelated"].ToString() != "") {
                    model.ProductRelated = ds.Tables[0].Rows[0]["ProductRelated"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Hits"] != null && ds.Tables[0].Rows[0]["Hits"].ToString() != "") {
                    model.Hits = int.Parse(ds.Tables[0].Rows[0]["Hits"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AddDateTime"] != null && ds.Tables[0].Rows[0]["AddDateTime"].ToString() != "") {
                    model.AddDateTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["AddDateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UpDateTime"] != null && ds.Tables[0].Rows[0]["UpDateTime"].ToString() != "") {
                    model.UpDateTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["UpDateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["XjIDs"] != null && ds.Tables[0].Rows[0]["XjIDs"].ToString() != "") {
                    model.XjIDs = ds.Tables[0].Rows[0]["XjIDs"].ToString();
                }
                return model;
            }
            else {
                return null;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere) {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM K_Product ");
            if (strWhere.Trim() != "") {
                strSql.Append(" where  1=1 " + strWhere);
            }
            return DbHelperOleDb.Query(strSql.ToString());
        }
        #endregion  Method

        #region K_Product开始
        public bool DeleteList(string IDlist) {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from K_Product ");
            strSql.Append(" where ID in (" + IDlist + ")  ");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0) {
                return true;
            }
            else {
                return false;
            }
        }

        public DataSet GetList(int Top, string strWhere, string filedOrder) {
            return this.GetList("*", Top, strWhere, filedOrder);
        }

        public DataSet GetList(int PageSize, int PageIndex, string strWhere, string strOrder, ref int RecordCount) {
            return this.GetList("*", PageSize, PageIndex, strWhere, strOrder, ref RecordCount);
        }

        public List<ModelProduct> GetModelList(string strWhere) {
            DataSet ds = this.GetList(strWhere);
            if (ds != null && ds.Tables[0].Rows.Count > 0) {
                return DBCommonHelper.FillModel<ModelProduct>(ds);
            }
            return null;
        }

        public List<ModelProduct> GetModelList(int Top, string strWhere, string filedOrder) {
            DataSet ds = this.GetList(Top, strWhere, filedOrder);
            if (ds != null && ds.Tables[0].Rows.Count > 0) {
                return DBCommonHelper.FillModel<ModelProduct>(ds);
            }
            return null;
        }

        public List<ModelProduct> GetModelList(int PageSize, int PageIndex, string strWhere, string strOrder, ref int RecordCount) {
            DataSet ds = this.GetList(PageSize, PageIndex, strWhere, strOrder, ref RecordCount);
            if (ds != null && ds.Tables[0].Rows.Count > 0) {
                return DBCommonHelper.FillModel<ModelProduct>(ds);
            }
            return null;
        }

        public DataSet GetList(string strFiled, string strWhere) {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select " + strFiled + " ");
            strSql.Append(" FROM K_Product ");
            if (strWhere.Trim() != "") {
                strSql.Append(" where 1=1 " + strWhere);
            }
            return DbHelperOleDb.Query(strSql.ToString());
        }

        public DataSet GetList(string strFiled, int Top, string strWhere, string filedOrder) {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0) {
                strSql.Append(" Top " + Top.ToString());
            }
            strSql.Append(" " + strFiled + " ");
            strSql.Append(" FROM K_Product ");
            if (strWhere.Trim() != "") {
                strSql.Append(" where 1=1 " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return DbHelperOleDb.Query(strSql.ToString());
        }

        public DataSet GetList(string strFiled, int PageSize, int PageIndex, string strWhere, string strOrder, ref int RecordCount) {
            StringBuilder strSqlCount = new StringBuilder();
            strSqlCount.Append("Select Count(*) as ID From K_Product ");
            if (strWhere.Trim() != "") {
                strSqlCount.Append(" where 1=1 " + strWhere);
            }
            RecordCount = Convert.ToInt32("0" + DbHelperOleDb.GetSingle(strSqlCount.ToString()));
            if (PageIndex <= 1) {
                PageIndex = 1;
            }
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select Top " + PageSize + " " + strFiled + " from K_Product where 1=1 ");
            if (strWhere.Trim() != "") {
                strSql.Append(" " + strWhere);
            }
            if (PageIndex > 1) {
                strSql.Append(" And ID Not In (Select Top " + ((PageIndex - 1) * PageSize) + " ID From K_Product Where 1=1 ");
                if (strWhere.Trim() != "") {
                    strSql.Append(" " + strWhere);
                }
                if (!string.IsNullOrEmpty(strOrder)) {
                    strSql.Append(" Order by " + strOrder);
                }
                strSql.Append(")");
            }
            if (!string.IsNullOrEmpty(strOrder)) {
                strSql.Append(" Order by " + strOrder);
            }
            return DbHelperOleDb.Query(strSql.ToString());
        }
        #endregion K_Product结束
    
    


    }
}
